package com.anlu.pattern.action.chain;

import com.anlu.pattern.action.template.OtherPayShopping;
import com.anlu.pattern.action.template.ShoppingCart;
import com.anlu.pattern.create.factory.simple.StaticFactory;
import com.anlu.pattern.common.entity.Fruit;

import java.util.ArrayList;
import java.util.List;

public class ChainClient {
    //初始化满减优惠券
    private static MultyDiscount multyDiscount = new FullMultyDiscount(null);

    static {
        multyDiscount = new NewerMultyDiscount(multyDiscount);
        multyDiscount = new SecondMultyDiscount(multyDiscount);
        multyDiscount = new HolidayMultyDiscount(multyDiscount);
    }

    public static void main(String[] args) {
        List<Fruit> products = new ArrayList<>();
        products.add(StaticFactory.getFruitApple());
        products.add(StaticFactory.getFruitBanana());
        products.add(StaticFactory.getFruitOrange());

        ShoppingCart cart = new OtherPayShopping(products);
        //注入优惠方案
        cart.setDiscount(multyDiscount);
        cart.submitOrder();
    }
}
